"""角色api"""

from flask import request
from src.api.origin import *
from src.schema import Schema
from src.core.role import Role_Info, Role_Manager


@basic_decorator()
def add_role(user):
    """添加角色"""
    schema = Schema.add_role(**request.get_json())
    return Role_Manager.add_role(schema, user)


@basic_decorator()
def roles_list(user):
    """获取角色列表"""
    schema = Schema.roles_list(**request.get_json())
    return Role_Info.roles_list(schema)


@basic_decorator()
def remove_role(user):
    """删除角色"""
    schema = Schema.remove_role(**request.get_json(force=True))
    return Role_Manager.remove_role(schema)


@basic_decorator()
def update_role(user):
    """更新角色信息"""
    schema = Schema.update_role(**request.get_json())
    return Role_Manager.update_role(schema)


@basic_decorator()
def role_info(user):
    """获取角色信息"""
    schema = Schema.role_info(**request.get_json())
    return Role_Info.role_info(schema)
